package com.sdhs.workflow.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 消息类型枚举
 *
 * @author may
 */
@Getter
@AllArgsConstructor
public enum UnifyToDoExeTypeEnum {
    /**
     * 待办添加
     */
    TO_DO_ADD("add", "待办添加"),

    /**
     * 待办修改
     */
    TO_DO_SET("set", "待办修改"),

    /**
     * 待办删除
     */
    TO_DO_DEL("del", "待办删除"),

    /**
     * 企业微信
     */
    WXWORK_SEND("WXWORK","企业微信发送");

    private final String code;

    private final String desc;

    private final static Map<String, UnifyToDoExeTypeEnum> MESSAGE_TYPE_ENUM_MAP = new ConcurrentHashMap<>(UnifyToDoExeTypeEnum.values().length);

    static {
        for (UnifyToDoExeTypeEnum messageType : UnifyToDoExeTypeEnum.values()) {
            MESSAGE_TYPE_ENUM_MAP.put(messageType.code, messageType);
        }
    }

    /**
     * 根据消息类型 code 获取 MessageTypeEnum
     * @param code 消息类型code
     * @return MessageTypeEnum
     */
    public static UnifyToDoExeTypeEnum getByCode(String code) {
        return MESSAGE_TYPE_ENUM_MAP.get(code);
    }
}

